package com.cloud.filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @BelongsProject: my
 * @BelongsPackage: com.cloud.filter
 * @Author: ji ge
 * @CreateTime: 2024-02-02  12:19
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class MyLogGateWayFilter implements GlobalFilter , Ordered {
    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        String uname = exchange.getRequest().getQueryParams().getFirst("uname");
        if (uname ==null){
            Mono<Void> voidMono = exchange.getResponse().setComplete();
            return voidMono;
        }
        return chain.filter(exchange);
    }

    @Override
    public int getOrder() {
        return 0;
    }
}
